module.exports = function(sequelize, DataTypes) {
  return sequelize.define(
    'Users',
    {
      id: {
        type: DataTypes.BIGINT,
        allowNull: false,
        primaryKey: true,
        autoIncrement: true
      },
      create_time: {
        type: DataTypes.DATE,
        allowNull: false
      },
      update_time: {
        type: DataTypes.DATE,
        allowNull: false
      },
      delete_time: {
        type: DataTypes.DATE,
        allowNull: true
      },
      email: {
        type: DataTypes.STRING,
        allowNull: true
      },
      wechat: {
        type: DataTypes.STRING,
        allowNull: true
      },
      phone: {
        type: DataTypes.STRING(36),
        allowNull: true
      },
      password: {
        type: DataTypes.STRING,
        allowNull: false
      },
      gender: {
        type: DataTypes.ENUM,
        values: ['0', '1'],
        allowNull: true
      },
      age: {
        type: DataTypes.INTEGER,
        allowNull: true
      },
      avatar: {
        type: DataTypes.STRING(100),
        allowNull: true
      },
      last_time: {
        type: DataTypes.DATE,
        allowNull: true
      },
      last_ip: {
        type: DataTypes.STRING,
        validate: {
          isIPv4: true
        },
        allowNull: true
      }
    },
    {
      tableName: 'q_users'
    }
  )
}
